/*
 * IPAddress.cpp
 *
 *  Created on: Mar 14, 2011
 *      Author: sms103
 */

#include "IPAddress.h"

IPAddress::IPAddress() {
	inet_pton(AF_INET, "127.0.0.1", &sin_addr);

}

//Sets IP address from an ip string. returns true on success
bool IPAddress::setAddrIPString(const char *ip_str){
	inet_pton(AF_INET, ip_str, &sin_addr);
	return true;
}

bool IPAddress::setAddrInAddr(struct in_addr * ip4addrStruct){
	memcpy(&sin_addr,ip4addrStruct,sizeof(sin_addr));
	return true;
}

//TODO implement hostname lookup. return true on success.
bool IPAddress::setAddrHostname(const char *hostname){
	return false;//not implemented yet..
}

struct in_addr * IPAddress::getInAddr(){
	return &sin_addr;
}

IPAddress::~IPAddress() {
	// TODO Auto-generated destructor stub
}
